/** @format */

import { resultsModel } from '../../../sdk'
import { CODE_TYPES } from '../../../errorCode'
import { getAwardValidTime } from '../../custom/getAwardValidTime'

export default async function checkPrizeExpired(context: IContext<IParams>, { activityInfo }: IControllerInfos, { awardInfo }: IPreCheckData) {
  // 若有过期时间，且已过期
  if (Date.now() > getAwardValidTime(activityInfo, awardInfo)) {
    return resultsModel.error(CODE_TYPES.ERROR_PRIZE_EXPIRED)
  }
}
